<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<meta charset="utf-8" />
	<title th:text="${application.project.projectName}"></title>
	<link rel="stylesheet" type="text/css" th:href="@{/index/css/index.css}" />
</head>

<body>

<img class="bgone" th:src="@{/index/img/1.jpg}" />
<img class="pic" th:src="@{/index/img/a.png}" />

<div class="table">
	<div class="wel" th:text="${application.project.projectName}"></div>
	<div class="wel1" th:text="${application.project.projectNameDesc}"></div>
	<div class="user">
		<div><img th:src="@{/index/img/yhm.png}" class="prefix-img"/></div>
		<input type="text" name="username" id="username" placeholder="用户名" />
	</div>
	<div class="password">
		<div><img th:src="@{/index/img/mm.png}" class="prefix-img"/></div>
		<input type="password" name="password" id="password" placeholder="密码"/>
	</div>
	<input class="btn" type="button" name="登录" value="登录" />
</div>

<script	th:src="@{/plugin/jquery/jquery.js}"></script>
<script	th:src="@{/plugin/layer/layer.js}"></script>
<script	th:src="@{/plugin/layui/layui.js}"></script>
<script	th:src="@{/js/base.js}"></script>
<script type="text/javascript">
    var ctx = '[[${#httpServletRequest.getContextPath()}]]';
</script>
<script type="text/javascript">
	// 解决iframe里面会显示首页的问题,这是shiro重定向的问题.
    if(window !=top){
        top.location.href=location.href;
    }
</script>
<script >
	$(function(){
	    // 监听回车事件
        $(document).keyup(function(event){
            if(event.keyCode ==13){
                login()
            }
        });
        // 登录按钮事件
	    $('.btn').on('click',function(e){
            login()
		});

	    // 登录
		function login(){
            var username = $('#username').val();
            var password = $('#password').val();
            if(base.isNull(username)){
                layer.msg('请输入用户名');
                return false;
            }

            if(base.isNull(password)){
                layer.msg('请输入密码');
                return false;
            }

            $.ajax({
                url : ctx+'/rbac/login',
                data :{
                    'username':username,
                    'password':password
                },
                type : 'post',
                success : function (res) {
                    if(!res.success){
                        layer.msg(res.msg,{icon: 2});
                        return false;
                    }

                    window.location.href = ctx + '/rbac/main';
                }
            });
		}
	});
</script>
</body>
</html>